package com.springcloud.demo.serviceribbon.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author zhouyang
 * @Description
 * @date 2018/08/07
 */
@Service
public class HiService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "hiError")
    public String hello(String name){
        return restTemplate.getForObject("http://eureka-client/test/hello?name=" + name, String.class);
    }

    public String hiError(String name){
        return "哈哈哈，报错了！！！ "+ name;
    }

}
